home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 43 / Mac Magazin and MacEasy Magazine CD - Issue 43.iso / Software / Mobiles Büro / Newton / Newton Entwickler / DIL 2.0 Sample Code ƒ / SoupDrink-Mac-4 / AppDialogs.c < prev    next >
Text File  |  1996-05-23  |  3KB  |  142 lines

  1. /*  
  2. **        File:      AppDialogs.c
  3. **
  4. **        Contains: Input and status utitiles for MacOS SoupDrink application
  5. **                For the main MacOS file, see "SoupDrink.c" in this folder
  6. **                For the main Windows file, see "SOUPDRNK.C" in the Windows folder
  7. **
  8. **                Nearly all of the DIL code can be found in the file "engine.c".
  9. **
  10. **        Written by:    Rob Langhorne, mods by David Fedor
  11. **
  12. **      Copyright © 1995-1996 by Apple Computer, Inc.  All rights reserved.
  13. **
  14. **      You may incorporate this sample code into your applications without
  15. **      restriction.  This sample code has been provided "AS IS" and the
  16. **      responsibility for its operation is 100% yours.  You are not
  17. **      permitted to modify and redistribute the source as "DTS Sample Code."
  18. **      If you are going to re-distribute the source, we require that you
  19. **      make it clear in the source that the code was descended from
  20. **      Apple-provided sample code, but that you've made changes.
  21. */
  22.  
  23. #include <Dialogs.h>
  24. #include <String.h>
  25. #include <Strings.h>
  26. #include "AppDialogs.h"
  27.  
  28. // ok_outline
  29. //
  30. // outlines the "OK" button with a heavy border
  31. ok_outline(DialogPtr theDialog,short item)
  32. {
  33.     CGrafPtr    oldPort;
  34.     short        itemType;
  35.     Rect        itemRect;
  36.     Handle        itemHdl;
  37.     
  38.     GetDItem(theDialog,item,&itemType,&itemHdl,&itemRect);
  39.     if((**(ControlHandle)itemHdl).contrlHilite == 0xff)        /* cntrl is inactive */
  40.         return 0;
  41.  
  42.     GetPort( (GrafPtr *)&oldPort);
  43.     SetPort(theDialog);
  44.     PenSize(3,3);
  45.     InsetRect(&itemRect,-4,-4);
  46.     FrameRoundRect(&itemRect,16,16);
  47.     PenSize(1,1);
  48.     SetPort( (GrafPtr)oldPort);
  49.     return 0;
  50. }
  51.  
  52. Boolean inputDialog(char *inputText, char* initString, char* label)
  53. {
  54.       DialogRecord     Dialog;
  55.       short            Item;
  56.     short            itemType;
  57.     Rect            itemRect;
  58.     Handle            txHdl;
  59.     Str255            tempStr ;
  60.     Str255            initStr ;
  61.     
  62.       GetNewDialog (kInputDialog, &Dialog, (WindowPtr)-1); /***** errors? */
  63.  
  64.  
  65.     GetDItem((DialogPtr)&Dialog, LABEL, &itemType, &txHdl, &itemRect);
  66.     strcpy((char*) initStr, label);
  67.     c2pstr((char*) initStr);
  68.     SetIText(txHdl,initStr);
  69.  
  70.     GetDItem((DialogPtr)&Dialog, INPUT_TEXT, &itemType, &txHdl, &itemRect);
  71.     strcpy((char*) initStr, initString);
  72.     c2pstr((char*) initStr);
  73.     SetIText(txHdl,initStr);
  74.     SelIText((DialogPtr)&Dialog, INPUT_TEXT, 0, 32767);  // select the text for them, in case they want to change it
  75.  
  76.     ok_outline ((DialogPtr)&Dialog, OK) ;
  77.       do 
  78.       {
  79.         ModalDialog (NULL, &Item);
  80.      } while ((Item != OK) && (Item != CANCEL)) ;
  81.     
  82.     if (Item == OK)
  83.     {
  84.         GetIText(txHdl,tempStr);
  85.         p2cstr(tempStr);
  86.     
  87.         strcpy(inputText, (char *)tempStr);
  88.     }
  89.     else
  90.         *inputText = '\0';    // zero-length string indicates cancel.
  91.         
  92.     CloseDialog ((DialogPtr)&Dialog);
  93.     
  94.     return true;
  95.  
  96. }
  97.  
  98.  
  99. void PostAlertMessage(char*a, char*b, char*c, char*d)
  100. {
  101.     Str255 aa, bb, cc, dd;
  102.     strcpy(( char*) aa, a); strcpy(( char*) bb, b); 
  103.     strcpy(( char*) cc, c); strcpy(( char*) dd, d);
  104.     ParamText(c2pstr((char*)aa), c2pstr((char*)bb), c2pstr((char*)cc), c2pstr((char*)dd));
  105.     Alert(kInfoDialog, nil);
  106. }
  107.  
  108.  
  109. /*
  110.  * ShowSplash
  111.  *
  112.  * Show our splash screen
  113.  */
  114. void ShowSplash(DialogPtr *splash) 
  115. {
  116.     long        pause;            //    For use in delay
  117.     Handle        Hdl=nil;        
  118.  
  119.     *splash = GetNewDialog(kSplashDialog, nil, (WindowPtr)-1) ;
  120.     if (*splash) {
  121.         SetPort(*splash);
  122.         ShowWindow(*splash);
  123.         DrawDialog(*splash);
  124.  
  125.         Delay(60L,&pause);
  126.     }
  127. }
  128.  
  129. /*
  130.  * HideSplash
  131.  *
  132.  * Hide our splash screen
  133.  */
  134. void HideSplash(DialogPtr splash) 
  135. {
  136.     if (splash) {
  137.         HideWindow(splash);
  138.         DisposeDialog(splash);
  139.     }
  140. }
  141.  
  142.